473,441 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

Visual Styles and Button Images

Hey,
I have come into a bit of a problem.
When Flatsyle is on system it will not show my images that i have set
in image list or just in image.
Also somethings i have found online do not work because i coded it to
change the flatstyles(if needed) to whatever theme the user is using.
This is the code that effects it:

private void RecursivelyFormatForWinXP(Control control)
{
for(int x = 0; x < control.Controls.Count; x++)
{
// If the control derives from ButtonBase,
// set its FlatStyle property to FlatStyle.System.
if(control.Controls[x].GetType().BaseType == typeof(ButtonBase))
{
((ButtonBase)control.Controls[x]).FlatStyle = FlatStyle.System;
}

// If the control holds other controls, iterate through them also.
if(control.Controls.Count > 0)
{
RecursivelyFormatForWinXP(control.Controls[x]);
}
}
}

and...

private void frmNonPOReceiptsEntry_Load(object sender,
System.EventArgs e)
{
// Makes sure Windows XP is running and
// a .manifest file exists for the EXE.
if(Environment.OSVersion.Version.Major > 4
& Environment.OSVersion.Version.Minor > 0
& System.IO.File.Exists(Application.ExecutablePath + ".manifest"))
{
// Iterate through the controls.
for(int x = 0; x < this.Controls.Count; x++)
{
// If the control derives from ButtonBase,
// set its FlatStyle property to FlatStyle.System.
if(this.Controls[x].GetType().BaseType == typeof(ButtonBase))
{
((ButtonBase)this.Controls[x]).FlatStyle = FlatStyle.System;
}
RecursivelyFormatForWinXP(this.Controls[x]);
}
}
}

So my question is how do i get my own images to show up on the
buttons?(if possible by using my image list)

Thank you to whoever can help.
Nov 16 '05 #1
2 5014
Hi,

I had a similar problem with tool tip buttons and a treeview that were loosing their images when using FlatStyle.System. I've solved my problem by calling Application.DoEvents() after calling Application.EnableVisualStyles() eg.

Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new MyForm());

I cant remember which post I got this from but its out there somewhere.

Hope this helps

Scott
"Curtis Wellborn" wrote:
Hey,
I have come into a bit of a problem.
When Flatsyle is on system it will not show my images that i have set
in image list or just in image.
Also somethings i have found online do not work because i coded it to
change the flatstyles(if needed) to whatever theme the user is using.
This is the code that effects it:

private void RecursivelyFormatForWinXP(Control control)
{
for(int x = 0; x < control.Controls.Count; x++)
{
// If the control derives from ButtonBase,
// set its FlatStyle property to FlatStyle.System.
if(control.Controls[x].GetType().BaseType == typeof(ButtonBase))
{
((ButtonBase)control.Controls[x]).FlatStyle = FlatStyle.System;
}

// If the control holds other controls, iterate through them also.
if(control.Controls.Count > 0)
{
RecursivelyFormatForWinXP(control.Controls[x]);
}
}
}

and...

private void frmNonPOReceiptsEntry_Load(object sender,
System.EventArgs e)
{
// Makes sure Windows XP is running and
// a .manifest file exists for the EXE.
if(Environment.OSVersion.Version.Major > 4
& Environment.OSVersion.Version.Minor > 0
& System.IO.File.Exists(Application.ExecutablePath + ".manifest"))
{
// Iterate through the controls.
for(int x = 0; x < this.Controls.Count; x++)
{
// If the control derives from ButtonBase,
// set its FlatStyle property to FlatStyle.System.
if(this.Controls[x].GetType().BaseType == typeof(ButtonBase))
{
((ButtonBase)this.Controls[x]).FlatStyle = FlatStyle.System;
}
RecursivelyFormatForWinXP(this.Controls[x]);
}
}
}

So my question is how do i get my own images to show up on the
buttons?(if possible by using my image list)

Thank you to whoever can help.

Nov 16 '05 #2
Yea see i have thought of that before but there is one problem. I call
my flatstyles in the form load because Im not always going to have it on
XP style. I have it finding what theme they use and having that play a
part. So my code on when to change my flatstyle and what to change it to
is in form load. So in form load once it finds the style then my immages
are taken away. If you knwo anything else or anyone who can help let me
know.

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Greg Raven | last post by:
I styled my links just the way I want them using CSS, but now my linked images have picked up these same styles. I've tried turning the styles off for the images with: a img { text-decoration:...
7
by: codeslayer | last post by:
Greetings to everyone in ‘forum-land': I have a problem that has plaguing me to no end. It is a CSS-related question, and I have not seen this question posted anywhere in forums or through...
9
by: Curtis Wellborn | last post by:
Hey, I have come into a bit of a problem. When Flatsyle is on system it will not show my images that i have set in image list or just in image. Also somethings i have found online does not work...
1
by: Glen | last post by:
Hey there, I've seen in several instances where certain (non-standard) visual styles on WinXP can cause the text on .Net form button controls to display incorrectly. Usually, the last letter of...
10
by: Robert Jacobson | last post by:
Hi, I'm develing a COM add-in for Microsoft Word XP that displays a form. I'd like to have the form display using the Windows XP theme. However, neither using a manifest nor calling...
3
by: Brian Henry | last post by:
here's something odd, maybe someone can explain it, when i turn on application.enablevisualstyles at application start before i do my application.run(context) command in the sub main, when the app...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
On my old workstation (development workstation) if I set Application/Enable XP visual styles - I was able to get/see the visual styles - like button borders highlighting when you run the mouse over...
0
jwwicks
by: jwwicks | last post by:
Introduction This tutorial describes how to use Visual Studio to create a new C++ program, compile/run a program, resume work on an existing program and debug a program. It is aimed at the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.